package com.security2.demo.controller;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName UserContoller
 * @Description 测试类
 * @Author Liujt
 * @Date 2020/1/15 14:23
 **/
@RestController
@RequestMapping(value = "/user")
public class UserController {

    @GetMapping("/me")
    public Object getCurrentUser(@AuthenticationPrincipal UserDetails user) {
        return user;
    }

    @PostMapping("/me")
    public Object postCurrentUser(@AuthenticationPrincipal UserDetails user) {
        return user;
    }
}
